package com.example.administrator.testdagger.thread;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;

/**
 * Description: 
 * ModelName:
 *
 * @author WangJQ
 *Create at:  2018/6/5 9:05
 * Company: 沈阳艾尔时代科技发展有限公司
 * Copyright: (c)2018 AIR Times Inc. All rights reserved.
 * @version 1.0
 */

public class ThreadPool {

    private Set set;
    private Queue<Runnable> queue;

    public ThreadPool(int size) {
        for (int i = 0; i < size; i++) {
            MyThread thread = new MyThread();
            thread.start();
            set.add(thread);
        }
        queue = new LinkedList();
    }


    private class MyThread extends Thread {
        @Override
        public void run() {
            super.run();
            while (true) {
                synchronized (queue){
                    Runnable current = queue.poll();
                    current.run();
                }
            }

        }
    }

}
